package footprint.kwlee.app.detail;

import footprint.kwlee.app.R;
import footprint.kwlee.app.db.*;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.Toast;

public class DetailDelete extends Activity {
	private Intent my_intent;
	private Fp_DatabaseHelper Fp_DatabaseHelper = null;
	private SQLiteDatabase db = null;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        my_intent = getIntent();
        String idx = my_intent.getStringExtra("id");
        Fp_DatabaseHelper = new Fp_DatabaseHelper(this.getApplicationContext());
        db = Fp_DatabaseHelper.getWritableDatabase();
        
        int number = db.delete(Fp_Database_sql.DETAILFOOTPRINT, "_id = ?", new String[]{idx});
        if(number > 0)
        {
        	Toast.makeText(this, getString(R.string.b_footdelok), 0).show();
        }
        else
        {
        	Toast.makeText(this, getString(R.string.b_footdelfail), 0).show();
        }
        
        setResult(RESULT_OK);
		finish();
		
	}
	protected void onDestroy() {
		super.onDestroy();
		
		if(db != null)
		{
			db.close();
		}
		
		if(Fp_DatabaseHelper != null)
		{
			Fp_DatabaseHelper.close();
		}
	} 
}
